
ENTRYOFFSET = 0xc0001500
PLATFORM = elf_i386

ASM = nasm
CC = gcc
LD = ld
CFLAGS = -m32 -I lib/ -I lib/kernel/ -I kernel/ -I device/ -c -fno-builtin -fno-stack-protector -Wno-implicit-function-declaration
OBJ = build/main.o build/print.o build/init.o build/interrupt.o build/kernel.o build/timer.o build/debug.o

run:
	nasm -I boot/include/ boot/mbr.S -o boot/mbr.bin
	nasm -I boot/include/ boot/loader.S -o boot/loader.bin
	nasm -f elf -o build/print.o lib/kernel/print.S
	nasm -f elf -o build/kernel.o kernel/kernel.S
	dd if=boot/mbr.bin of=hd60M.img bs=512 count=1 conv=notrunc
	dd if=boot/loader.bin of=hd60M.img bs=512 seek=2 count=4 conv=notrunc
	$(CC) $(CFLAGS) -o build/main.o kernel/main.c 
	$(CC) $(CFLAGS) -o build/interrupt.o kernel/interrupt.c 
	$(CC) $(CFLAGS) -o build/init.o kernel/init.c 
	$(CC) $(CFLAGS) -o build/timer.o device/timer.c 
	$(CC) $(CFLAGS) -o build/debug.o kernel/debug.c 
	$(LD) -m $(PLATFORM) -s -Ttext $(ENTRYOFFSET) -e main -o kernel.bin $(OBJ)
	dd if=kernel.bin of=hd60M.img bs=512 count=200 seek=9 conv=notrunc
	rm -rf *.o kernel/*.o


